{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "73bd968b-d970-4a05-94ef-4e7abf990827",
   "metadata": {},
   "source": [
    "Chapter 01\n",
    "\n",
    "# 减法\n",
    "Book_3《数学要素》 | 鸢尾花书：从加减乘除到机器学习 (第二版)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23e2bb33-4777-45cc-90ad-fb20f2f1ce9a",
   "metadata": {},
   "source": [
    "该代码计算并输出两个数字之间的差值。首先，它定义了两个数字$5$和$3$，分别赋值给变量`num1`和`num2`，然后通过减法运算求出它们的差。 \n",
    "\n",
    "### 代码细节\n",
    "\n",
    "1. **计算差值**：代码通过减法计算`num1`和`num2`的差值，并将结果存储在变量`diff`中。计算公式为：\n",
    "\n",
    "   $$\n",
    "   \\text{diff} = \\text{num1} - \\text{num2}\n",
    "   $$\n",
    "\n",
    "   代入数值后，结果为：\n",
    "\n",
    "   $$\n",
    "   \\text{diff} = 5 - 3 = 2\n",
    "   $$\n",
    "\n",
    "2. **结果显示**：代码使用格式化字符串将计算结果输出到屏幕上，显示为“`The difference of 5 and 3 is 2`”。\n",
    "\n",
    "### 总结\n",
    "\n",
    "该代码简单地演示了如何进行基本的减法运算以及如何通过格式化输出结果。它展示了通过变量存储计算结果并使用格式化字符串将计算细节输出的过程。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff843b05-e211-4e3d-ba1c-445430d2d618",
   "metadata": {},
   "source": [
    "## 计算两个数字的差值并显示结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dd24d931-2562-4cb4-b398-2fb520d704b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "num1 = 5  # 定义第一个数字\n",
    "num2 = 3  # 定义第二个数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40f507f3-c38e-485d-9841-95c270e82715",
   "metadata": {},
   "source": [
    "## 计算两个数字的差值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9447c235-e3b3-4d79-8a11-d49e6082b977",
   "metadata": {},
   "outputs": [],
   "source": [
    "diff = num1 - num2  # 计算num1和num2的差值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4888afa-5b77-49b9-8c68-512ef1679d1e",
   "metadata": {},
   "source": [
    "## 显示计算结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "575aa4fc-4dd2-44a3-bbda-4c3d21adce51",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The difference of 5 and 3 is 2\n"
     ]
    }
   ],
   "source": [
    "print('The difference of {0} and {1} is {2}'.format(num1, num2, diff))  # 输出两个数字的差值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85a80909-2aac-49ed-bb7a-f8cc6b80ee7d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecd322f4-f919-4be2-adc3-69d28ef25e69",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
